package com.chif.goingplus.controller;

import com.chif.goingplus.pojo.Work;
import com.chif.goingplus.service.WorkService;
import com.chif.goingplus.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@RequestMapping("/work")
public class WorkController {
    @Autowired
    private WorkService workService;

    @RequestMapping("/add")
    public String addBus(Work work){
        return workService.addWork(work)+"";
    }

    @RequestMapping("/delete")
    public String deleteBusById(int id){
        workService.deleteWorkById(id);
        return "删除任务信息成功";
    }

    @RequestMapping("/query")
    public String queryBusById(int id){
        return JsonUtils.getJson(workService.queryWorksByEmp(id));
    }

    @RequestMapping("/update")
    public String updateBus(Work work){
        workService.updateWork(work);
        return "修改任务信息成功";
    }


}
